package MD2Model;

/**
 * This class define a frame of the Model
 * it will include one scale vector specify the scale index of model,
 * one translate vertor specify the translate index of model
 * one char array specify the name of frame
 * one vertex array hold the list of frame's vertices
 * @author gameloft
 *
 */
public class Frame {
	private Vector3 scale; /* scale factor */
	private Vector3 translate; /* translation vector */
	private char name[]; /* frame name */
	private Vertex verts[]; /* list of frame's vertices */

	/**
	 * Constructor
	 */
	public Frame () {
		name = new char[16];
		scale = new Vector3();
		translate = new Vector3();
	}
	
	/**
	 * Set name for this frame
	 * @param name one String specify the name
	 */
	public void SetName (char[] name){
		this.name = name;
	}
	
	/**
	 * get the name of this frame
	 * @return the name of this frame
	 */
	public String GetName (){
		int i = 0;
		for(i=0; i<name.length; i++){
			if(Character.isDigit(name[i])) break;
		}
		return new String(name).substring(0, i).trim();
	}

	/**
	 * Set Scale vector for frame
	 * @param v which will be apply for scale vector.
	 */
	public void SetScale (Vector3 vec){
		scale = vec;
	}
	
	/**
	 * Get the scale vector of the frame
	 * @return scale
	 */
	public Vector3 GetScale (){
		return scale;
	}
	
	/**
	 * Set translate vector
	 * @param v which will be apply for translate vector of frame
	 */
	public void SetTranslate (Vector3 vec){
		translate = vec;
	}
	
	/**
	 * Get the translate vector of the frame
	 * @return translate
	 */
	public Vector3 GetTranslate (){
		return translate;
	}
	
	/**
	 * Get the Vertex at the specified location
	 * @param index the location of vertex to return
	 * @return the vertex at index location
	 */
	public Vertex GetVertex (int index) {
		return verts[index];
	}
	
	/**
	 * Set size of vertices in frame
	 * @param n number of dimension
	 */
	public void SetVerticesSize (int n){ //set size of vertices in frame
		verts = new Vertex[n];
		for(int i = 0; i<n; i++) {
			verts[i] = new Vertex();
		}
	}
}
